﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MyVoteMVC.Web.Models.Activity>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    活动列表
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">    
    
   <div id="gridWrap">
    <% Html.Telerik().Grid(Model)
        .Name("Grid")
        .DataKeys(keys=>keys.Add(o=>o.ID))
        .Columns(columns =>
        {
            columns.Bound(o => o.ID).HeaderHtmlAttributes(new { @style = "display:none" });            
        })
        .RowTemplate((o, grid) =>
          {           
    %>
        <div class="employee-details" aid="<%= (o.IfReadAll.HasValue && o.IfReadAll.Value > 0)?("/Home/ProjectDetails/" + o.ID):("/Home/ItemDetails/" + o.ID)%>">
            <img class="t-widget" src='<%= Url.Content("~/Image/ThumbnailByActivityID/")+o.ID %>'
                alt='<%= o.Title %>' />
            <h3 class="t-widget">
                <%= o.Title%></h3>
            <dl>
                <dt>开始时间:</dt><dd><%= o.StartTime %></dd>
                   <dt>结束时间:</dt><dd><%= o.EndTime %></dd>
                </dl>
                <dl class="t-widget">
                   <dt>查看人数:</dt><dd><%= o.View_Count %></dd>
                   <dt>参与人数:</dt><dd><%= o.Ticket_Count %></dd>
                </dl>
            </div>
          <%         
          }
        )        
        .Groupable(settings => settings.Groups(groups =>
        {
            groups.Add(o => o.CurrentState);
        }).Visible(false))
        .ClientEvents(events => events.OnRowSelected("onRowSelected").OnLoad("adjustHeight"))
        .Footer(false)
        .Scrollable(o=>o.Height(800))
        .Selectable()
        
        .Render();
%>
</div>

<script type="text/javascript">
    function onRowSelected(e) {
        // get the DOM element which represents the clicked row
        var row = e.row;
        // get the instance of the grid client-side object
        var grid = $(this).data("tGrid");
        // use the dataItem method of the grid to get the data item to which the row is bound to
        var dataItem = grid.dataItem(row);

        // use the obtained data item for something e.g. navigate to a new page passing some property as an argument

        location.href = $("div", row).eq(0).attr("aid");
    }

    function adjustHeight(e) {

        // wh: Grid wrapper height

        // gh: Grid height

        // gc: Grid content area



        var wh = $("#gridWrap").innerHeight();

        var gh = $(this).outerHeight();

        if (wh > gh) {

            var gc = $(".t-grid-content", this);

            gc.height(gc.height() + wh - gh);

        }

    }

</script>

</asp:Content>
<asp:Content ID="Content3" contentPlaceHolderID="HeadContent" runat="server">
    <style type="text/css">
        .employee-details
        {
            padding:.8em .6em;
            display:inline-block;
        }
        .employee-details
        {
            display:block;
        }
        
        .employee-details:after
        {
            content:"";
            display:block;
            clear:both;
        }
        
        .employee-details dl,
        .employee-details dt,
        .employee-details dd
        {
            margin:0;
            padding:0;
        }
        
        .employee-details img,
        .employee-details h3,
        .employee-details dl,
        .commands
        {
            float:left;
            clear:none;
            margin:0 14px 0 0;
        }

        .employee-details h3,
        .employee-details dl
        {
            width:200px;
            min-height:115px;
            border-width:0 1px 0 0;
            background-color:transparent;
            color:inherit;
        }
        
        .employee-details h3
        {
            width:90px;
            padding:0;
            font-size:1.5em;
            padding-right:20px;
        }
        
        .employee-details dt
        {
            font-weight:bold;
        }

    .field-validation-error
    {
        position: absolute;
        display: block;
    }
    
    * html .field-validation-error { position: relative; }
    *+html .field-validation-error { position: relative; }
    
    .field-validation-error span
    {
        position: absolute;
        white-space: nowrap;
        color: red;
        padding: 17px 5px 3px;
        background: transparent url('<%= Url.Content("~/Content/Common/validation-error-message.png") %>') no-repeat 0 0;
    }
    
    /* in-form editing */
    .t-edit-form-container
    {
        width: 350px;
        margin: 1em;
    }
    
    .t-edit-form-container .editor-label,
    .t-edit-form-container .editor-field
    {
        padding-bottom: 1em;
        float: left;
    }
    
    .t-edit-form-container .editor-label
    {
        width: 30%;
        text-align: right;
        padding-right: 3%;
        clear: left;
    }
    
    .t-edit-form-container .editor-field
    {
        width: 60%;
    }
    </style>
</asp:Content>